/*************************************************************************
	> File Name: main.cc
	> Author: H.M. Lau
	> Mail: hm.lau@outlook.com
	> Created Time: 2023/10/25 20:31
 ************************************************************************/

#include "dfa_minimize_machine.hpp"
#include "nfa.hpp"
#include "nfa_interpretor.hpp"
#include "macro_handler.hpp"
#include "dfa_constructor.hpp"
#include "push_down_stack.hpp"
#include <memory>

const std::string macro = "../file/macro";
const std::string reg = "../file/reg";
const std::string push_dfa = "../file/push_dfa";

void test1()
{
    std::cout << "Please input your macro:" << std::endl;
    MacroHandler handler;
    handler.defMacro(macro);
    std::cout << "Please input your Regular Expression:" << std::endl;
    auto v = handler.expandMacro(reg);
    for (const auto& e : v) {
        nfa::Nmc nmc(e);
        nfa::NfaPair nfapair;
        nmc.expr(&nfapair);
#ifdef DEBUG_SHOW
        nfa::NfaHandler::showNfa(&nfapair);
#endif
        nfa::NfaInterpretor interpretor;
        std::cout << "Please input your word to be lexed:" << std::endl;
        interpretor.nfaMatchStr(nfapair._start);
        dfa::DfaConstructor dfa_constructor(&nfapair, &nmc);
        dfa_constructor.convertNfaToDfa();
        auto ori_table = dfa_constructor.getDfaTransTable();
#ifdef DEBUG_SHOW
        std::cout << "\nDFA original table:" << std::endl;
        dfa::DfaConstructor::printDfaTable(ori_table);
#endif
        std::unique_ptr<dfa::DfaMinMachine> dfa_min_machine(new dfa::DfaMinMachine(&dfa_constructor));
        auto min_table = dfa_min_machine->minimize();
#ifdef DEBUG_SHOW
        std::cout << "\nDFA minimized table:" << std::endl;
        dfa::DfaConstructor::printDfaTable(min_table);
#endif
    }
}
    
void test2()
{
    dfa::PushDownDfa pdd;
    pdd.recogParenthese();
}

int main(int argc, char *argv[])
{
    test2();
    return 0;
}
